package com.learning.seata.demo.service.impl;

import com.learning.seata.demo.service.BusinessService;
import com.learning.seata.demo.service.OrderService;
import com.learning.seata.demo.service.StorageService;
import io.seata.spring.annotation.GlobalTransactional;

public class BusinessServiceImpl implements BusinessService {

    private StorageService storageService;

    private OrderService orderService;

    /**
     * 采购.我们只需要使用一个 @GlobalTransactional 注解在业务方法上:
     */
    @Override
    @GlobalTransactional
    public void purchase(String userId, String commodityCode, int orderCount) {

        storageService.deduct(commodityCode, orderCount);

        orderService.create(userId, commodityCode, orderCount);
    }
}